<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <title></title>

</head>
<body>
   <script type="text/javascript">
        var str = ' 12  323 s'
        var str1 = str.replace(/^\s*|\s*$/g, '')
        console.log(str1)
   </script>
</body>
</html>